<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="menu" content="mainMenu" />
<meta name="nav" content="0" />
<meta name="acc" content="1" />
<title>用户管理</title>
<!--  通用情况下 不引入 js css  表单验证  js 放置到页面中 -->
<script>
$(document).ready(
	function() {
	//聚焦第一个输入框
	$("#userName").focus();
	//为inputForm注册validate函数
	$("#inputForm")
			.validate(
		{
			rules : {
				userName : {
					required : true,
					remote : "user!checkLoginName.action?oldLoginName="
							+ encodeURIComponent('${userName}')
				},
				name : "required",
				password : {
					required : true,
					minlength : 3
				},
				passwordConfirm : {
					equalTo : "#password"
				},
				email :{
					email:true,
					remote:"user!checkregisterEmail.action?oldEmail="+encodeURIComponent('${email}')
				} ,
				checkedRoleIds : "required"
			},
			messages : {
				userName : {
					remote : "<font color='red'>用户登录名已存在</font>"
				},
				passwordConfirm : {
					equalTo : "<font color='red'>输入与上面相同的密码</font>"
				}
			}
		});
		});

	function changeExternalOrgName() {
		var orgId = $("input[name='orgId']").val();
		var url = "";
		if (orgId) {
			url = "<c:url value='/account/api/external_organization.action?id='/>"
					+ orgId;
		} else {
			url = "<c:url value='/account/api/external_organization.action'/>"
		}
		var obj = new Object();
		mm = window
				.showModalDialog(
						url,
						obj,
						'dialogHeight:500px;dialogWidth:780px;status:no;toolbar:no;resizable:no;menubar:no;location:no;scrollbars:no;dialogLeft:'
								+ (screen.width / 2.0 - 150) + ',dialogTop:170')
		if (mm != null) {
			$("input[name='orgId']").val(mm.id);
			$("input[name='orgName']").val(mm.orgName);
		}
	}
	function changeInsideOrgName() {
		var orgId = $("input[name='orgId']").val();
		var url = "";
		if (orgId) {
			url = "<c:url value='/account/api/inside_organization.action?id='/>"
					+ orgId;
		} else {
			url = "<c:url value='/account/api/inside_organization.action'/>"
		}
		var obj = new Object();
		mm = window
				.showModalDialog(
						url,
						obj,
						'dialogHeight:500px;dialogWidth:780px;status:no;toolbar:no;resizable:no;menubar:no;location:no;scrollbars:no;dialogLeft:'
								+ (screen.width / 2.0 - 150) + ',dialogTop:170')
		if (mm != null) {
			$("input[name='orgId']").val(mm.id);
			$("input[name='orgName']").val(mm.orgName);
		}
	}
</script>
</head>

<body>

	<!-- 直接主体内容开始  无需要涉及页面布局的  div 等   注意各页面中的Id 保持一致  页面中尽量用 el表达式 与html标签->
<!--   form定义 类似如下:  注意各页面中的Id 保持一致  class="inputForm"-->
	<form id="inputForm" action="${ctx }/account/user!save.action" method="post"
		class="yform">
		<div id="caption"><h6>用户管理</h6></div>
		<table class="noborder">
			<tr class="type-text">
				<td>用&nbsp;户&nbsp;名&nbsp;:</td>
				<td><input type="text" id="userName" name="userName"
					value="${userName}" /></td>
			</tr>
			<tr class="type-text">
				<td>姓&nbsp;&nbsp;&nbsp;&nbsp;名&nbsp;:</td>
				<td><input type="text" name="name" id="name" value="${name}" />
				</td>
			</tr>
			<tr class="type-text">
				<td>密&nbsp;&nbsp;&nbsp;&nbsp;码&nbsp;:</td>
				<td><input type="password" id="password" name="password"
					value="123456" /></td>
			</tr>
			<tr class="type-text">
				<td>确认密码&nbsp;:</td>
				<td><input type="password" id="passwordConfirm"
					name="passwordConfirm" value="123456" />
				</td>
			</tr>
			<tr class="type-text">
				<td>邮&nbsp;&nbsp;&nbsp;&nbsp;箱&nbsp;:</td>
				<td><input type="text" id="email" name="email" value="${email}" />
				</td>
			</tr>
				<tr class="type-text">
					<td>用户管理&nbsp;:</td>
					<td>
						<s:checkbox name="enable"  value="true" fieldValue="1"></s:checkbox>可用
						<s:checkbox name="expired"  value="false" fieldValue="1"></s:checkbox>帐号过期
						<s:checkbox name="locked"   value="false" fieldValue="1" ></s:checkbox>锁定
						<s:checkbox name="credexpired"   value="false"  fieldValue="1"></s:checkbox>密码过期
					</td>
				</tr>
			<tr class="type-check">
				<td>角&nbsp;&nbsp;&nbsp;&nbsp;色&nbsp;:</td>
				<td>
				<s:checkboxlist name="checkedRoleIds" list="allRoleList"
						listKey="id" listValue="roleName" theme="custom" />
				</td>
			</tr>
			<c:if test="${id == null }">
				<tr class="type-text">
					<td>所属单位:</td>
					<td><s:select name="org.id"  list="insideorganizationList" listKey="id" listValue="orgName"></s:select> </td>
				</tr>
			</c:if>
		</table>
					<div class="type-button">
						<input   type="submit" class="submit" value="提交" />&nbsp;
						<input   type="reset" value="返回" class="reset"
							onclick="history.back()" />
					</div>
	</form>
</body>
</html>
